<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <title>替换元素</title>
    <style>
        div {
            display: inline-block;
            width: 100px;
            height: 50px;
            border: 1px solid gray;
        }
    </style>
    <script src="jQuery-3.6.3.min.js"></script>
    <script>
        $(function () {
            $("#a1").click(function () {
                var a = $("div").width();
                alert(a);
            });
        })
    </script>
</head>
<body>
    <div>
        <p>hello</p>
    </div>
    <input id="a1" type="button" value="替换" />
</body>
</html>